﻿using MediatR;
using SheepStorage.API.Application.Command.BodySizeCommand;
using SheepStorage.API.Application.Command.SheepConditionCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepConditionHandler
{
    public class SheepConditionListHandler : IRequestHandler<SheepConditionListCommand, Results<PageOutput<SheepCondition>>>
    {
        private readonly ISheepConditionService service;

        public SheepConditionListHandler(ISheepConditionService service)
        {
            this.service = service;
        }

        public async Task<Results<PageOutput<SheepCondition>>> Handle(SheepConditionListCommand request, CancellationToken cancellationToken)
        {
            return Results<PageOutput<SheepCondition>>.DataResult(await service.GetSheepCondition(request.overBit, request.SheepType, request.SheepConditionSex, request.pageIndex, request.pageSize));
        }
    }
}
